import fetch from '@/utils/request'

const API_LOGIN_URL = '/api/user/login';

/**
 * 登录API对象
 * @module Login
 */
const Login = {
	/**
	 * @function login
	 * @description 手机验证码登录
	 * @param  {Object} login 登录对象 {}
	 * @param  {String} sms sms
	 */
	login: (login, sms) => fetch.request({
		url: `${API_LOGIN_URL}/unify`,
		method: 'POST',
		data: {
			login: login,
			verify_code_key: sms
		}
	}),
	/**
	 * @function mpweixin
	 * @description 微信授权登录
	 * @param  {Object} login 登录对象 {}
	 */
	mpweixin: (login) => fetch.request({
		url: `${API_LOGIN_URL}/mpweixin/oauth`,
		method: 'POST',
		data: {
			oauth: login
		}
	}),
	/**
	 * @function mpbingd
	 * @description 微信授权绑定
	 * @param  {Object} login 登录对象 {}
	 */
	mpbingd: (data) => fetch.request({
		url: `/api/user/bind/mpweixin`,
		method: 'POST',
		data: {
			oauth:data
		}
	}),
	/**
	 * @function h5weixin
	 * @description H5微信授权登录
	 * @param  {Object} login 登录对象 {}
	 */
	h5weixin: (login) => fetch.request({
		url: `${API_LOGIN_URL}/wechat/oauth`,
		method: 'POST',
		data: login
	}),

	// mpResolvePhone: (login) => fetch.request({
	// 	url: '/api/user/login/mpweixin/resolve_phone',
	// 	method: 'POST',
	// 	data: login
	// }),
	/**
	 * @function appweixin
	 * @description APP微信授权登录
	 * @param  {Object} login 登录对象 {}
	 */
	appweixin: (login) => fetch.request({
		url: `${API_LOGIN_URL}/appweixin/oauth`,
		method: 'POST',
		data: login
	}),
}
export default Login